﻿using DDU.Infrastructure;
using System;
using System.Collections.Generic;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Text;

namespace DDU.DataModel
{
    [Table(Name = "T_Exams")]
    public class ExaminationInfo : NotificationObject
    {
        #region Fields
        private string _guid = System.Guid.NewGuid().ToString();
        private string _semesterGuid;
        private string _title;
        private DateTime _startTime = DateTime.Now;
        private DateTime _endTime = DateTime.Now.AddMinutes(90); 
        #endregion

        #region Properties
        [Column(IsPrimaryKey=true)]
        public string Guid
        {
            get { return _guid; }
            set
            {
                _guid = value;
                RaisePropertyChanged(() => Guid);
            }
        }

        [Column]
        public string SemesterGuid
        {
            get { return _semesterGuid; }
            set
            {
                _semesterGuid = value;
                RaisePropertyChanged(() => SemesterGuid);
            }
        }

        [Column]
        public string Title
        {
            get { return _title; }
            set
            {
                _title = value;
                RaisePropertyChanged(() => Title);
            }
        }

        [Column]
        public DateTime StartTime
        {
            get { return _startTime; }
            set
            {
                _startTime = value;
                RaisePropertyChanged(() => StartTime);
            }
        }

        [Column]
        public DateTime EndTime
        {
            get { return _endTime; }
            set
            {
                _endTime = value;
                RaisePropertyChanged(() => EndTime);
            }
        }

        public int ExamCount
        {
            get;
            set;
        }
        #endregion

        #region Event
        public event EventHandler<PropertyArgs> ValueChanged = delegate { };

        protected override void RaisePropertyChanged(string propertyName)
        {
            base.RaisePropertyChanged(propertyName);
            ValueChanged.Invoke(this, new PropertyArgs()
            {
                Property = GetType().GetProperty(propertyName)
            });
        }
        #endregion
    }
}
